package com.zhang.repository;

import com.zhang.entity.UserSalt;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * 21级 计科院·张艺澄
 * 2024.12.8
 */
public interface UserSaltRepository extends JpaRepository<UserSalt, Integer>, JpaSpecificationExecutor<UserSalt> {

    /**
     * 根据用户id删除所有关联信息
     * @param userId
     */
    @Query(value="delete from t_user_salt where user_id=?1",nativeQuery=true)
    @Modifying
    public void deleteByUserId(Integer userId);


    /**
     * 根据角色id删除所有关联信息
     * @param saltId
     */
    @Query(value="delete from t_user_salt where salt_id=?1",nativeQuery=true)
    @Modifying
    public void deleteBySaltId(Integer saltId);
}
